//
// Created by Felix on 24-5-7.
//

#ifndef GAZE_USERUPDATEDETAILSDTOVALIDATE_HPP
#define GAZE_USERUPDATEDETAILSDTOVALIDATE_HPP

#include "service/UserService.hpp"

class UserUpdateDetailsDtoValidate {
public:
    static bool validateUniqueUsername(
            UserService &iUserService,
            const oatpp::Object<UserUpdateDetailsDto> &dto
    ) {
        if (dto->username->empty()) return false;
        auto user = iUserService.getUserByUsernameFilterOutUserId(
                dto->username, dto->userId
        );
        if (user) return false;
        return true;
    }

    static bool validateRequireUserId(
            UserService &iUserService,
            const oatpp::Int32 &userId
    ) {
        if (userId <= 0) return false;
        auto user = iUserService.getUserById(userId);
        if (!user) return false;
        return true;
    }

    static bool validateRequireStatus(
            const oatpp::Object<UserUpdateDetailsDto> &dto
    ) {
        switch (dto->status) {
            case 1:
            case 2:
                return true;
            default:
                return false;
        }
    }
};

#endif //GAZE_USERUPDATEDETAILSDTOVALIDATE_HPP
